p_height=4;
p_width=4;
phase3_x_max=11;

input_file="/home/dongjin2/SVNROOT/switch-ext/rinse_test_cases/Exp1/FairQ_5_90/p2.txt"
output_file="/home/dongjin2/SVNROOT/switch-ext/rinse_test_cases/Exp1/FairQ_5_90/plot_phase2.pdf"

data=scan(file=input_file);
max_num=max(data)+1;
#x_limit=max(max_num, phase2_x_max)
bin=seq(-0.5,max_num,by=1)

#x11();
#postscript(output_name, height=p_height, width=p_width, horizontal=FALSE, onefile=TRUE);
pdf(output_file, height=p_height, width=p_width, onefile=TRUE);

#The four numbers in the call to par are the number of lines of text reserved on the bottom, left, top and right, respectively, ps: text size, mpg: margin size for title, axis label and axis
#saved_par=par(mar=c(2.5,2.5,0.3,0.1)+0.1, ps=10, mgp=c(1.5, 0.5,0), mfrow=c(1,3));
saved_par=par(mar=c(2.2,2,1,0.1)+0.1, ps=8, mgp=c(1.3, 0.5, 0));

hist(data, col="lightblue", breaks=bin, right=F, xlim=c(0, max_num), ylab="Number of Time Steps", xlab="Number of Depedent Ports", main="TOP1, FairQ, COV=5, Link Utilization = 90%");

par(saved_par);
dev.off()

input_file2="/home/dongjin2/SVNROOT/switch-ext/rinse_test_cases/Exp1/FairQ_5_90/p3.txt"
output_file2="/home/dongjin2/SVNROOT/switch-ext/rinse_test_cases/Exp1/FairQ_5_90/plot_phase3.pdf"
data2=scan(file=input_file2);
max_num2=max(data2)+1;
x_limit2=max(max_num2, phase3_x_max)
bin2=seq(-0.5,x_limit,by=1)

pdf(output_file2, height=p_height, width=p_width, onefile=TRUE);
saved_par=par(mar=c(2.2,2,1,0.1)+0.1, ps=8, mgp=c(1.3, 0.5, 0));
hist(data2, col="lightblue", breaks=bin2, right=F, xlim=c(0, x_limit2), ylab="Number of Time Steps", xlab="Number of Iterations", main="TOP1, FairQ, COV=5, Link Utilization = 90%");
par(saved_par);
dev.off()


